package javacommon.util;


public class Base64FileUtils {

//	private static Log log = LogFactory.getLog(Base64FileUtils.class);
//	public static Attach saveFile(HttpServletRequest request,String name,String attch){
//		log.info("收到文件上传请求");
//		Attach attach = new Attach();
//		String ext = FilenameUtils.getExtension(name);
//		log.info("文件后缀 "+ext);
//		String currentDate = Common.getCurrentDate3()+(new Random().nextInt(10000));
//		String attachSrc = Common.ATTACH_IMG_SRC+currentDate+"."+ext;
//		log.info("文件路径"+attachSrc);
//		try {
//			File file = new File(request.getSession().getServletContext().getRealPath("/")+attachSrc);
//			OutputStream ot = new FileOutputStream(file);
//			BASE64Decoder decoder = new BASE64Decoder();
//			byte[] result = decoder.decodeBuffer(attch);
//			IOUtils.write(result, ot);
//			IOUtils.closeQuietly(ot);
//			attach.setExt(ext);
//			attach.setFileName(FilenameUtils.getBaseName(attachSrc));
//			attach.setPath(attachSrc);
//			return attach;
//		} catch (IOException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//			return null;
//		}
//	}
}


//String result = request.getParameter("image")          
//byte[] result = Base64.decode()  
//OutputStream out = new FileOutputStream("C:\\a.png");  
//out.write(result);  
//out.close();